<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@page import="java.util.ArrayList"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="css/main.css" />
<link rel="stylesheet" type="text/css" href="../js/style.css" />
<script language="javascript" src="../js/PopupCalendar.js" ></script>
<title>湖北包装网会员管理系统</title></head>
<body>
<script language="javascript" src="../js/area2.js"></script>
<script type="text/javascript" src="../js/jquery.min.js"></script> 
<script type="text/javascript" language="javascript"> 
$(function(){ 
//Bind the change event 
$("#company_type").unbind("change", eDropLangChange).bind("change", eDropLangChange); 
$("#company_type_info").unbind("change", eDropFrameChange).bind("change", eDropFrameChange); 
}); 

//The change event of language dropdown-list 
var eDropLangChange = function(){ 
//The selected value of the language dropdown-list. 
var selectedValue = $(this).val(); 

//show all options. 
$("#company_type_info").children("span").each(function(){ 
$(this).children().clone().replaceAll($(this)); //use the content of the <span> replace the <span> 
}); 

//Filter the data through selected value of language dropdown-list except <Please Select>. 
//If the option is <Please Select>, it only needs to show all and hide nothing. 
if(parseInt(selectedValue) != 0){ 
//hide the option whose parentid is not equal with selected value of language dropdown-list. 
//The <Please Select> option should not be hidden. 
$("#company_type_info").children("option[parentid!='" + selectedValue + "'][value!='0']").each(function(){ 
$(this).wrap("<span style='display:none'></span>"); //add a <span> around the <option> and hide the <span>. 
}); 
} 
}; 

//The change event of frame dropdown-list. 
var eDropFrameChange = function(){ 
//Find the selected option of frame dropdown-list. set the value of language dropdown-list by selected parentid. 
$("#company_type").val($(this).children("option:selected").attr("parentid")); 
}; 
</script> 

<%@   page   import="com.us.indagate.pojo.Indagate"%>
<%@   page   import="com.us.user.pojo.CompanyType"%>
<%@   page   import="com.us.user.pojo.CompanyTypeInfo"%>
 <%@   page   import="java.util.Date"%>
 <%@   page   import="java.util.List"%>    
  <%@   page   import="java.lang.Integer"%>   
  <%@   page   import="java.io.File"%>   
  <%@   page   import="jxl.Workbook"%>   
  <%@   page   import="jxl.WorkbookSettings"%>   
  <%@   page   import="jxl.Range"%>   
  <%@   page   import="jxl.write.WritableWorkbook"%>   
  <%@   page   import="jxl.write.WritableSheet"%>   
  <%@   page   import="jxl.write.WritableFont"%>   
  <%@   page   import="jxl.write.WritableCellFormat"%>   
  <%@   page   import="jxl.write.NumberFormats"%>   
  <%@   page   import="jxl.write.DateFormats"%>   
  <%@   page   import="jxl.write.Label"%>   
  <%@   page   import="jxl.write.Number"%>   
  <%@   page   import="jxl.write.DateTime"%>   
  <%@   page   import="jxl.write.NumberFormat"%>   
  <%@   page   import="jxl.write.DateFormat"%>   
  <%@   page   import="jxl.write.WriteException"%>   
  <%@   page   import="jxl.write.WritableHyperlink"%>   
  <%@   page   import="jxl.write.Boolean"%>   
  <%@   page   import="jxl.write.Formula"%>   
  <%@   page   import="jxl.format.Alignment"%>   
  <%@   page   import="jxl.format.VerticalAlignment"%>   
  <%@   page   import="jxl.format.Border"%>   
  <%@   page   import="jxl.format.BorderLineStyle"%>   
  <%@   page   import="jxl.format.Colour"%>   
  <%@   page   import="jxl.format.UnderlineStyle"%>   
  <%@   page   import="jxl.format.ScriptStyle"%>   
  <%@   page   import="jxl.format.Orientation"%>   
  <%@   page   import="jxl.format.PageOrientation"%>   
  <%@   page   import="jxl.format.PaperSize"%>   
  <%   
  boolean bExportSucc   =   false;   
  String   sErrorStr="";   
    
  String   sHead="/files/";   
  String   sFileName="Test.xls";   
  String   sCurrPath=application.getRealPath(sHead);   
  if(!sCurrPath.substring(sCurrPath.length()-1).equals("/"))sCurrPath=sCurrPath+"/";   
  sCurrPath=sCurrPath+sFileName;   
            
  //获取文件的URL地址   
  String   sAttachServer="localhost:8080/packaging";   
  if(sAttachServer.length()==0)   
  sAttachServer=request.getServerName()+":"+request.getServerPort();   
  String   sUrlPath="http://"+sAttachServer+sHead+sFileName;   
    
    
  //以下开始输出到EXCEL   
  try   {   
  /************创建工作簿*************/   
  WritableWorkbook   workbook   =   Workbook.createWorkbook(new   File(sCurrPath));   
  /************创建工作表*************/   
  WritableSheet   sheet   =   workbook.createSheet("普查分析结果",   0);   
  /************设置页眉、页脚******************/   
  sheet.setHeader("页眉","","第   &P   页，共   &N   页");   //设置页眉   
  sheet.setFooter("","","&D   &T");   //设置页脚   
  /******注：以上这些&P、&D等参数可以从EXCEL的宏录制取得********/   
    
  /***********设置列宽*****************/   
  sheet.setColumnView(0,13);   //第1列   
  sheet.setColumnView(1,26);   //第2列   
  sheet.setColumnView(2,13);   
  sheet.setColumnView(3,26);   
    
    
  /**************设置单元格字体***************/   
  WritableFont   NormalFont   =   new   WritableFont(WritableFont.ARIAL,10);   
  WritableFont   BoldFont   =   new   WritableFont(WritableFont.ARIAL,14,WritableFont.BOLD);   
    
  /**************以下设置几种格式的单元格*************/   
  //用于标题   
  WritableCellFormat   wcf_title   =   new   WritableCellFormat(BoldFont);   
  wcf_title.setBorder(Border.NONE,   BorderLineStyle.THIN);   //线条   
  wcf_title.setVerticalAlignment(VerticalAlignment.CENTRE);   //垂直对齐   
  wcf_title.setAlignment(Alignment.CENTRE);   //水平对齐   
  wcf_title.setWrap(false);   //是否换行   
    
  //用于正文左   
  WritableCellFormat   wcf_left   =   new   WritableCellFormat(NormalFont);   
  wcf_left.setBorder(Border.ALL,   BorderLineStyle.THIN);   //线条   
  wcf_left.setVerticalAlignment(VerticalAlignment.CENTRE);   //垂直对齐   
  wcf_left.setAlignment(Alignment.LEFT);   
  wcf_left.setWrap(true);   //是否换行   
    
  //用于正文右   
  WritableCellFormat   wcf_right   =   new   WritableCellFormat(NormalFont);   
  wcf_right.setBorder(Border.ALL,   BorderLineStyle.THIN);   //线条   
  wcf_right.setVerticalAlignment(VerticalAlignment.CENTRE);   //垂直对齐   
  wcf_right.setAlignment(Alignment.RIGHT);   
  wcf_right.setWrap(false);   //是否换行   
    
  //用于跨行   
  WritableCellFormat   wcf_merge   =   new   WritableCellFormat(NormalFont);   
  wcf_merge.setBorder(Border.ALL,   BorderLineStyle.THIN);   //线条   
  wcf_merge.setVerticalAlignment(VerticalAlignment.TOP);   //垂直对齐   
  wcf_merge.setAlignment(Alignment.LEFT);   
  wcf_merge.setWrap(true);   //是否换行   
  /**************单元格格式设置完成*******************/   
    
  /*****************以下是标题***************************/   
  sheet.mergeCells(0,0,33,0);   //合并单元格   
  sheet.addCell(new   Label(0,0,"普查分析结果",wcf_title));   
  /*****************以下是字段内容**********************/ 
  
  sheet.addCell(new   Label(0,1,"单位名称",wcf_right)); 
  sheet.addCell(new   Label(1,1,"专业类别",wcf_right));
  sheet.addCell(new   Label(2,1,"专业类别子类",wcf_right)); 
  sheet.addCell(new   Label(3,1,"详细地址",wcf_right)); 
  sheet.addCell(new   Label(4,1,"邮编",wcf_right)); 
  sheet.addCell(new   Label(5,1,"法人代表",wcf_right)); 
  sheet.addCell(new   Label(6,1,"法人代表性别",wcf_right)); 
  sheet.addCell(new   Label(7,1,"法人代表电话",wcf_right)); 
  sheet.addCell(new   Label(8,1,"法人代表传真",wcf_right)); 
  sheet.addCell(new   Label(9,1,"法人代表邮箱",wcf_right)); 
  sheet.addCell(new   Label(10,1,"总经理姓名",wcf_right)); 
  sheet.addCell(new   Label(11,1,"总经理性别",wcf_right)); 
  sheet.addCell(new   Label(12,1,"总经理电话",wcf_right));
  sheet.addCell(new   Label(13,1,"总经理传真",wcf_right)); 
  sheet.addCell(new   Label(14,1,"总经理邮箱",wcf_right)); 
  
  sheet.addCell(new   Label(15,1,"联系人姓名",wcf_right)); 
  sheet.addCell(new   Label(16,1,"联系人性别",wcf_right));
  sheet.addCell(new   Label(17,1,"联系人电话",wcf_right)); 
  sheet.addCell(new   Label(18,1,"联系人传真",wcf_right)); 
  sheet.addCell(new   Label(19,1,"联系人邮箱",wcf_right)); 
  sheet.addCell(new   Label(20,1,"经济性质",wcf_right)); 
  sheet.addCell(new   Label(21,1,"企业等级",wcf_right)); 
  sheet.addCell(new   Label(22,1,"企业代码",wcf_right)); 
  sheet.addCell(new   Label(23,1,"建厂时间",wcf_right)); 
  sheet.addCell(new   Label(24,1,"职工人数",wcf_right)); 
  sheet.addCell(new   Label(25,1,"技术人员",wcf_right)); 
  sheet.addCell(new   Label(26,1,"占地面积",wcf_right)); 
  sheet.addCell(new   Label(27,1,"生产范围",wcf_right));
  sheet.addCell(new   Label(28,1,"固定资产总值",wcf_right)); 
  sheet.addCell(new   Label(29,1,"工业总产值",wcf_right));
  
  sheet.addCell(new   Label(30,1,"流动资金",wcf_right)); 
  sheet.addCell(new   Label(31,1,"销售收入",wcf_right)); 
  sheet.addCell(new   Label(32,1,"上缴税金",wcf_right));
  sheet.addCell(new   Label(33,1,"利润",wcf_right));  
    
  
  /*****************以下是定单内容**********************/   
  List list = new ArrayList();
  list = (List)request.getAttribute("indagateList");
  for(int i=0;i<list.size();i++){
  	  sheet.addCell(new   Label(0,2+i,((Indagate)list.get(i)).getCom_name(),wcf_right)); 
  	  List typelist = new ArrayList();
  	  typelist = (List)request.getAttribute("LinkageList");
  	  for(int j=0;j<typelist.size();j++){
  	  	int a = Integer.parseInt(((Indagate)list.get(i)).getCom_type());
  	  	int b = ((CompanyType)typelist.get(j)).getType_id();
  	  	if(a==b){
  	  		sheet.addCell(new   Label(1,2+i,((CompanyType)typelist.get(j)).getType_name(),wcf_right));
  	  	}
  	  	
  	  }
	  List typelistinfo = new ArrayList();
  	  typelistinfo = (List)request.getAttribute("LinkageinfoList");
  	  for(int j=0;j<typelistinfo.size();j++){
  	  	int a = Integer.parseInt(((Indagate)list.get(i)).getCom_type());
  	  	int b = ((CompanyTypeInfo)typelistinfo.get(j)).getInfo_id();
  	  	if(a==b){
  	  		sheet.addCell(new   Label(2,2+i,((CompanyTypeInfo)typelistinfo.get(j)).getInfo_name(),wcf_right));
  	  	}
  	  	
  	  }
	  sheet.addCell(new   Label(3,2+i,((Indagate)list.get(i)).getCom_address(),wcf_right));
	  sheet.addCell(new   Label(4,2+i,((Indagate)list.get(i)).getCom_zip(),wcf_right));  
	  sheet.addCell(new   Label(5,2+i,((Indagate)list.get(i)).getCom_legal(),wcf_right)); 
	  sheet.addCell(new   Label(6,2+i,((Indagate)list.get(i)).getCom_legal_sex(),wcf_right)); 
	  sheet.addCell(new   Label(7,2+i,((Indagate)list.get(i)).getCom_legal_tel(),wcf_right)); 
	  sheet.addCell(new   Label(8,2+i,((Indagate)list.get(i)).getCom_legal_fax(),wcf_right)); 
	  sheet.addCell(new   Label(9,2+i,((Indagate)list.get(i)).getCom_legal_mail(),wcf_right)); 
	  sheet.addCell(new   Label(10,2+i,((Indagate)list.get(i)).getManage_name(),wcf_right)); 
	  sheet.addCell(new   Label(11,2+i,((Indagate)list.get(i)).getManage_sex(),wcf_right)); 
	  sheet.addCell(new   Label(12,2+i,((Indagate)list.get(i)).getManage_tel(),wcf_right)); 
	  sheet.addCell(new   Label(13,2+i,((Indagate)list.get(i)).getManage_fax(),wcf_right));
	  sheet.addCell(new   Label(14,2+i,((Indagate)list.get(i)).getManage_mail(),wcf_right)); 
	  sheet.addCell(new   Label(15,2+i,((Indagate)list.get(i)).getContact_name(),wcf_right)); 
	  
	  sheet.addCell(new   Label(16,2+i,((Indagate)list.get(i)).getContact_sex(),wcf_right)); 
	  sheet.addCell(new   Label(17,2+i,((Indagate)list.get(i)).getContact_tel(),wcf_right));
	  sheet.addCell(new   Label(18,2+i,((Indagate)list.get(i)).getContact_fax(),wcf_right)); 
	  sheet.addCell(new   Label(19,2+i,((Indagate)list.get(i)).getContact_mail(),wcf_right)); 
	  sheet.addCell(new   Label(20,2+i,((Indagate)list.get(i)).getEconomic_nature(),wcf_right)); 
	  sheet.addCell(new   Label(21,2+i,((Indagate)list.get(i)).getCom_code(),wcf_right)); 
	  sheet.addCell(new   Label(22,2+i,((Indagate)list.get(i)).getCom_level(),wcf_right)); 
	  sheet.addCell(new   Label(23,2+i,((Indagate)list.get(i)).getCom_builddate(),wcf_right)); 
	  sheet.addCell(new   Label(24,2+i,((Indagate)list.get(i)).getWorkers_num(),wcf_right)); 
	  sheet.addCell(new   Label(25,2+i,((Indagate)list.get(i)).getTechnology_num(),wcf_right)); 
	  sheet.addCell(new   Label(26,2+i,((Indagate)list.get(i)).getCom_area(),wcf_right)); 
	  sheet.addCell(new   Label(27,2+i,((Indagate)list.get(i)).getProduction_range(),wcf_right)); 
	  sheet.addCell(new   Label(28,2+i,((Indagate)list.get(i)).getFixed_assets(),wcf_right));
	  sheet.addCell(new   Label(29,2+i,((Indagate)list.get(i)).getTal_indust_output_val(),wcf_right)); 
	  sheet.addCell(new   Label(30,2+i,((Indagate)list.get(i)).getCom_liquidity(),wcf_right));
	  
	  sheet.addCell(new   Label(31,2+i,((Indagate)list.get(i)).getCom_sales(),wcf_right)); 
	  sheet.addCell(new   Label(32,2+i,((Indagate)list.get(i)).getCom_tax(),wcf_right)); 
	  sheet.addCell(new   Label(33,2+i,((Indagate)list.get(i)).getCom_rofit(),wcf_right)); 

  }
   
    
  
   
    
  /************以上所写的内容都是写在缓存中的，下一句将缓存的内容写到文件中*********/   
  workbook.write();   
  /***********关闭文件**************/   
  workbook.close();   
  bExportSucc   =   true;   
  }   catch(Exception   e){   
  sErrorStr   =   e.toString();   
  System.out.println("在输出到EXCEL的过程中出现错误，错误原因："+e.toString());   
  }   
  %> 
  
<jsp:include page="adminTitle.jsp" flush="true"></jsp:include>
<div id="mainpage">
  <div class="bodytitle">
    <div class="bodytitleleft"></div>
    <div class="bodytitletxt">普查结果分析 </div>
  </div>
  <div>
  <form action="../indagate/IndagateSearch.action" method="post">
  	<table align="center" id="comusertable" >
  		<tr>
  			<td style="font-size: 12px">
  			固定资产总值：
  					<select size="1" id="indagate.fixed_assets" name="indagate.fixed_assets"><option value="0-10万元">0-10万元</option>
                      <option value="10-100万元">10-100万元</option>
                      <option value="100-1000万元">100-1000万元</option>
                      <option value="1000万-1亿元">1000万-1亿元</option>
                      <option value="1亿元以上">1亿元以上</option>
                    </select>
            </td>
            <td style="font-size: 12px">
  			工业总产值：
  					<select size="1" id="indagate.tal_indust_output_val" name="indagate.tal_indust_output_val"><option value="0-10万元">0-10万元</option>
                      <option value="10-100万元">10-100万元</option>
                      <option value="100-1000万元">100-1000万元</option>
                      <option value="1000万-1亿元">1000万-1亿元</option>
                      <option value="1亿元以上">1亿元以上</option>
                    </select>
            </td>
  			
  			
            
  			<td style="font-size: 12px">
  			专业类别：
  			<select id="company_type" name="indagate.com_type">
  				<option value="">请选择专业类别</option>
                		<s:iterator value="LinkageList">
                			<option value="<s:property value="type_id"/>" ><s:property value="type_name"/> </option>
                		</s:iterator>
  			</select> 
  			<select id="company_type_info" name="indagate.com_type_info">
                	<option value="">请选择专业类别子类</option>
                		<s:iterator value="LinkageinfoList">
                			<option value="<s:property value="info_id"/>" parentid="<s:property value="type_id"/>"><s:property value="info_name"/> </option>
                		</s:iterator>
                	</select>
  			</td>
  			
  		</tr>
  		<tr>
  		<td style="font-size: 12px">
  			销售收入：
  					<select size="1" id="indagate.com_sales" name="indagate.com_sales"><option value="0-10万元">0-10万元</option>
                      <option value="10-100万元">10-100万元</option>
                      <option value="100-1000万元">100-1000万元</option>
                      <option value="1000万-1亿元">1000万-1亿元</option>
                      <option value="1亿元以上">1亿元以上</option>
                    </select>
            </td>
            
            <td style="font-size: 12px">
  			利润：
  					<select size="1" id="indagate.com_rofit" name="indagate.com_rofit"><option value="0-10万元">0-10万元</option>
                      <option value="10-100万元">10-100万元</option>
                      <option value="100-1000万元">100-1000万元</option>
                      <option value="1000万-1亿元">1000万-1亿元</option>
                      <option value="1亿元以上">1亿元以上</option>
                    </select>
            </td>
  			<td>
					<select id="province"></select>
					<select id="city"></select>
					<select id="county"></select>
				
				<input type="submit" value="查询" /><a href="<%=sUrlPath%>"><font size="2"> 导出excel</font></a> 
				
			</td>
  		</tr>
  	</table>
  	</form>
  </div>
  <table cellpadding="0" cellspacing="0" border="0" id="table" class="sortable">
		<thead>
			<tr>
				<th class="nosort"><h3>单位名称</h3></th>
				<th><h3>专业类别</h3></th>
				<th><h3>专业类别二级</h3></th>
				<th class="nosort"><h3>详细信息</h3></th>
			</tr>
		</thead>
		<tbody>
		<s:iterator value="indagateList" id="culist">
			<tr>
				<td><font size="2px"><s:property value="#culist.com_name"/></font></td>
				<td><font size="2px">
				<s:iterator value="LinkageList" id="llist">
				<s:if test="#culist.com_type==#llist.type_id"><s:property value="#llist.type_name"/></s:if>
				</s:iterator>
				</font></td>
				<td><font size="2px">
				<s:iterator value="LinkageinfoList" id="lflist">
				<s:if test="#culist.com_type_info==#lflist.info_id"><s:property value="#lflist.info_name"/></s:if>
				</s:iterator>
				</font></td>
				<td><img src="img/ico-edit.gif" onclick='location.href="../user/comUserView.action?user_id=<s:property value="#culist.user_id"/>"' style="cursor: hand"/></td>
			</tr>
		</s:iterator>
		</tbody>
  </table>
	<div id="controls">
		<div id="perpage">
			<select onchange="sorter.size(this.value)">
			    <option value="5">5</option>
				<option value="10" selected="selected">10</option>
				<option value="20">20</option>
				<option value="50">50</option>
				<option value="100">100</option>
			</select>
			<span><font size="2px">输入分页条数</font></span>
		</div>
		<div id="navigation">
			<img src="../js/images/first.gif" width="16" height="16" alt="First Page" onclick="sorter.move(-1,true)" />
			<img src="../js/images/previous.gif" width="16" height="16" alt="First Page" onclick="sorter.move(-1)" />
			<img src="../js/images/next.gif" width="16" height="16" alt="First Page" onclick="sorter.move(1)" />
			<img src="../js/images/last.gif" width="16" height="16" alt="Last Page" onclick="sorter.move(1,true)" />
		</div>
		<div id="text"><font size="2px">显示页面： <span id="currentpage"></span> of <span id="pagelimit"></span> </font></div>
	</div>
	<script type="text/javascript" src="../js/script.js"></script>
	<script type="text/javascript">
    var sorter = new TINY.table.sorter("sorter");
	sorter.head = "head";
	sorter.asc = "asc";
	sorter.desc = "desc";
	sorter.even = "evenrow";
	sorter.odd = "oddrow";
	sorter.evensel = "evenselected";
	sorter.oddsel = "oddselected";
	sorter.paginate = true;
	sorter.currentid = "currentpage";
	sorter.limitid = "pagelimit";
	sorter.init("table");<!-- sorter.init("table",0);参数表示选中第几列  -->
	sorter.size(10);
  </script>
</div>
</body>
</html>
<!--js初始化函数-->
			<SCRIPT language="javascript">
			setup()
			</SCRIPT>